package com.hwadee.ems.domain.vo;

import java.time.Year;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hwadee.ems.domain.po.Class;
import com.hwadee.ems.service.IMajorService;
import com.hwadee.ems.service.impl.DepartmentServiceImpl;
import com.hwadee.ems.service.impl.MajorServiceImpl;
import com.hwadee.ems.service.IDepartmentService;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class ClassVO {

    @JsonIgnore
    private IMajorService majorService = MajorServiceImpl.getInstance();

    @JsonIgnore
    private IDepartmentService departmentService = DepartmentServiceImpl.getInstance(); 

    public ClassVO(Class classEntity) {
        this.id = classEntity.getId();
        this.grade = classEntity.getGrade();
        this.majorId = classEntity.getMajorId();
        this.majorName = majorService.getById(classEntity.getMajorId()).getName();
        this.name = classEntity.getName();
        this.studentCount = classEntity.getStudentCount();
        this.departmentId = classEntity.getDepartmentId();
        this.departmentName = departmentService.getById(classEntity.getDepartmentId()).getName();
    }

    /**
     * 班级编号
     */
    private Long id;

    /**
     * 年级
     */
    private Year grade;

    /**
     * 专业编号 references major(id) for (name)
     */
    private Long majorId;

    /**
     * 专业名称
     */
    private String majorName;

    /**
     * 班级名称，如：21软工R5
     */
    private String name;

    /**
     * 学生人数
     */
    private Integer studentCount;

    /**
     * 院系编号 references department(id) for (name)
     */
    private Long departmentId;

    /**
     * 院系名称
     */
    private String departmentName;

}
